home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / visds / multidlg.dsc < prev    next >
Text File  |  1999-05-02  |  3KB  |  88 lines

  1.     title Child Dialog Test
  2. REM Demonstrate creating and using a child dialog
  3.   DIALOG CREATE,Main Dialog,20,20,220,166,SAVEPOS Main
  4.   DIALOG ADD,LIST,LIST1,10,10,198,96
  5.     DIALOG ADD,BUTTON,Add,116,10,,,,default
  6.   DIALOG ADD,BUTTON,Close,116,144,64,24
  7.   DIALOG ADD,STATUS,SB,Click Add to add an item of text to the list
  8.   DIALOG SHOW
  9. :Main_evloop
  10.     wait event
  11.     %E = @event()
  12.     goto %E
  13.  
  14. :AddBUTTON
  15.     goto Child_Dialog
  16.  
  17. :CloseBUTTON
  18. :CLOSE
  19.     exit
  20.  
  21. :Child_Dialog
  22.     DIALOG CREATE,Child Dialog,20,0,284,72,SAVEPOS Child,NOMIN
  23.     DIALOG ADD,EDIT,CEDIT1,10,10
  24.     DIALOG ADD,BUTTON,OK,8,206,,,,default
  25.   DIALOG ADD,BUTTON,Cancel,36,206,64,24
  26.   DIALOG ADD,BUTTON,Help,36,10,64,24,Help
  27.   DIALOG SHOW
  28.     
  29. REM With a non-modal child dialog any of the buttons and dialog
  30. REM elements can generate events, including those on other dialogs,
  31. REM and so you have to find out which dialog they came from by
  32. REM using @event(D). For most applications, as here, while the
  33. REM child dialog is showing you don't want to respond to events
  34. REM from the main window so the usual response is to sound a warning
  35. REM beep and activate the dialog the user is supposed to be using.
  36.  
  37. REM It is possible to write scripts in which events can legitimately
  38. REM be received from any dialog that is showing (such as the VDS
  39. REM Dialog Designer) but this is complicated stuff for advanced
  40. REM programmers only.
  41.  
  42. REM The main advantage of using a non-modal DIALOG SHOW is that
  43. REM it allows you to do other things while the child dialog is
  44. REM active. Here, we validate that some data has been entered in
  45. REM the edit box, and display a warning if there isn't any. We have
  46. REM also added a Help button which could be used to call up online
  47. REM help.
  48.     
  49. :Child_evloop
  50.     wait event
  51.     parse "%E;%D",@event(D)
  52.     if @zero(%D)
  53.         beep
  54.         dialog select,1
  55.         dialog focus,CEDIT1
  56.         goto Child_evloop
  57.     else
  58.         goto Child_%E
  59.     end
  60.     
  61. :Child_HelpBUTTON
  62.     info You clicked the Help button!
  63.     goto Child_evloop
  64.     
  65. :Child_OKBUTTON
  66.     dialog select,1
  67.     %A = @dlgtext(cedit1)
  68.     if @null(%A)
  69.         warn No data entered!
  70.         goto Child_evloop
  71.     end
  72.     dialog select,0
  73.     list add,list1,%A
  74.     dialog select,1
  75.     
  76. :Child_CancelBUTTON
  77. :Child_CLOSE
  78. REM Even in the event of clicking the close button, you must still
  79. REM explicitly close the child dialog. This is to give you a chance
  80. REM to recover any data from it.
  81.     DIALOG CLOSE
  82. REM Wait for the CLOSE event that this generates...
  83.     wait event
  84. REM ...and throw it away (otherwise it will be executed by the main
  85. REM event loop!)
  86.     %E = @event()
  87.     goto Main_evloop
  88.